The knowledge of mIRC Identifiers is very crucial before you can even think of writing any impressive or very useful script. That's the reason why I am covering it before mIRC Commands and Remote. Actually the knowledge of the available mIRC Identifiers will give you some idea about the things you can do with mIRC script. Identifiers are very important, remember that.
Now what is an Identifier? In simple words I'd say it's a value which returns (outputs) predefined values about mIRC, components of scripts, IRC status and parameters, system files, properties numbers and many many more. Not just that, some Identifiers perform functions (works) on values you feed it with.
Want to see how an Identifier looks like? Ok here's one:
$me So, have you seen it before? Or what about
$ip? These two are very commonly used Identifiers. $me returns your nickname. And $ip returns your IP number. Now, isn't it cool? You don't have to type your 9 characters-long-nick in 100 places in your script. Or still better the 32 bits IP number. What's more, no matter what you change your nick to or your IP changes to, $me and $ip will output the changed value accordingly.
There are two types of Identifiers: Inbuilt and Custom. Inbuilt Identifiers are Identifiers created by and reserved for mIRC. Custom Identifiers are Identifiers you create for your own use in scripts. Creating custom Identifiers with the same name as inbuilt Identifiers with the hope of overwriting it is a fruitless job, don't even think of it. And with this understanding, you must be cautious in naming your custom Identifiers, it shouldn't be already reserved by an inbuilt Identifier. Or else you'd get unexpected results.
Now we go for a general explanation on how Identifiers work with some examples. We'll start with inbuilt Identifiers. I will also be listing some commonly used and useful Identifiers in the end. The total number of inbuilt Identifiers in mIRC is quite large and since they are already documented in the Help File, I understand I won't need to invent the wheel again by listing and explaining all of them here.
Type
//say my nick is $me
in mIRC, you will get "my nick is <your nickname>". You can use the $me Identifier to call your nickname from a script. Try implementing it in an alias. Well, when you call an Identifier (variable also) from a command line you need to use double front slashes (//) to make mIRC evaluate the value. Or else you it will echo the unevaluated strings, which, in this case will be "my nick is $me". Try echoing using a single slash and see the result for yourself.
Now we'll see an example of an Identifier which processes the values fed to it. The best example would be the
$calc()
Identifier. It performs mathematical calculations on the values. Type the following codes below in the command line and observe.
//echo -a 2+3 = $calc(2+3)
//echo -a The value of Pi is $calc(22/7)
//echo -a When you multiply 5 by itself you get $calc(5*5)
Now, that was just one of the many Identifiers from the Text and Numbers category of Identifiers. Look up the Help File and read up all the Identifiers. Anyone who wants to be an able scripter should atleast know all the Identifiers from the following categories: Time and Date, File and Directories, Nick and Address, Text and Numbers, Remote Identifiers and Other Identifiers. Rest of the Identifiers, you can learn as you start writing more complex scripts and when necessary.
Custom Identifiers
You must have noticed in some scripts, Identifiers that you couldn't find in the mIRC Help File. Well, that's what custom Identifiers are - Identifiers created by the scripter himself/herself. Custom Identifiers are actually aliases but with a difference in how they are written and work.
Since custom Identifiers are actually aliases, you have two ways to create them. You can either create them from the command line or from a remote file. In the following examples I am using remote to create the alias. Read in the
Remotes section how to do it.
If you haven't forgotten, normal aliases are created in a script this way:
alias poke
me
pokes $1 $+ .
Custom Identifiers, this way:
alias song
return
All I really need is someone like Phoebe. Someone to excite my fantasy.
Custom Identifiers are aliases created using the
/return (the / is optional) command. Regular aliases use other mIRC commands like /me, /echo, /notice etc. In the above example we have created a custom Identifier called
$song
. Now type
//say $song
This time I won't tell you what you will get, do it and see for yourself. Assuming you have done what I told you to, you can see how useful a custom Identifier can be. The same result can be gotten by the use of a variable too, we'll see it in the chapter on
Variables. Custom Identifiers offer more ability in some regards. But that doesn't mean custom Identifiers can always replace variables. They are useful in their own ways.
Custom Identifiers can be used, apart from printing out songs or whatever, for processing texts and numbers fed to it. In the next example we create one of them. We'll create a custom Identifier called
$add(). It will do what it's name says, add, which will be equivalent to
$calc(N1 + N2). $add() will add the first two numbers fed to it. And since it performs an arithmetic function we will be using the $calc() Identifier inside it. The code follows:
alias add return $calc($1 + $2)
To see the custom Identifier in action type
//echo -a $add(2,4)
Try all sort of things on it. Use alphabets in place of numbers, include a third number etc. And see for yourself what you get. That's the true hacker's spirit. Now create the $add() Identifier in following two different ways and see what you get:
alias add return $calc($1 + $2 + $3 + $4)
alias add {
if ($3) {
return This Identifier can add only two numbers. Cut the $3- off!
halt
}
else return $calc($1 + $2)
}
Here's another Identifier we'll create. We'll name it
$conc(), because it will concatenate the values fed to it. Any value, num or alph or alphnum or special characters. The code for the Identifier follows:
alias conc return $1 $+ $2
Very simple and easy huh? $+ is used to concatenate (join) parameters in scripts. It's a very useful
Operator. You will need it in many places once you start writing complex scripts. Now, some of you may ask "What's the use of $conc() when $+ already does the job with fewer keystrokes?" Well, what it does is show you how to create custom Identifiers and their possible uses. If you asked that question, probably you won't be able to come up with many imaginative uses of the custom Identifiers. He he. Anyway, Type
//echo -a $conc(2,y) to see $conc() in action.
The next example is actually intended to introduce you to more complex scripting. We create a custom Identifier called
$checkit(). This custom Identifier checks for the number of values fed to it. If it's two, it checks the type of the values input. If both are numbers it adds them, else it concatenates them. If there is a third or more parameter, the Identifier ... see for yourself what it does. To follow this example you need to have a good knowledge about conditions (
If-Else) and Identifiers too, of course. If you don't understand the coding, you can always come back here after you read about
If-Else. The code follows:
alias checkit {
if (!$3) {
if (($1 isnum) && ($2 isnum)) return $1 and $2 ADDED: $calc($1 + $2)
else return $1 and $2 CONCATENATED: $1 $+ $2
}
else return $3- caused an error in processing $1 and $2
}
Do I have to tell you how to see this custom Identifier in action? Well, I guess I don't. But if you think I should, press Alt+F4.
These custom Identifiers are really cool. They can even have their own properties! Things such as
$frog().color,
$frog().size and
$frog().shape. Now we'll create a simple custom identifier called
$frog() with the properties color, size and shape. It will return the properties of the frog who's name you submit as the object parameter.
alias frog {
if ($1 == Mark) {
if ($prop == $null) return The available properties are color, size and shape.
if ($prop == color) return spotty green
if ($prop == size) return 3"x2"
if ($prop == shape) return triangular
else return $prop is not a valid property.
}
if ($1 == Laura) {
if ($prop == $null) return The available properties are color, size and shape.
if ($prop == color) return bright green
if ($prop == size) return 2"x1"
if ($prop == shape) return triangular
else return $prop is not a valid property.
}
if ($1 == $null) return Enter the name of the frog to lookup.
else return $1 not in the International Frogs Database (IFD).
}
Copy and paste the above code in your Remote. You will soon get to see this amazing script in action. This is just a very simple example. No complexities involved or else the whole purpose of this tutorial will make no sense. Using Hash tables instead of storing the data in the script file you could actually create an International Frogs Database with many more properties. To see the $frog() identifier in action type the following in the mIRC command line.
//echo -a Mark, a $frog(mark).color colored frog is married to Laura, who is $frog(laura).color in color.
//echo -a $frog()
//echo -a $frog(Laura)
//echo -a $frog(Mark).looks
//echo -a $frog(Mary).color
//echo -a Laura measures $frog(Laura).size $+ .
How do you get Laura's shape? Mark's size? Use the identifier in an alias? That's your homework.
Look at the output and study the code. Does it make sense? I bet it does. The thing you put after the brackets following the identifier name is called the property of the identifier (.color, .size.shape). For the properties to work you should have already defined them under the identifier, as you can see in the above example. The identifier
$prop returns the property passed by the custom identifier.
The mIRC Help File has got one nice example on using properties for custom identifiers. I give it below. Paste it in Remote.
alias add {
%x = $1 + $2
if ($prop == negative) return $calc(-1 * %x)
return %x
}
Type
//echo Total is: $add(1,2).negative to see the above example in action. Try without the negative property too.
That was all about custom identifiers. They can come very handy in many situations. When and where you use them depends on your creativity and need.
Ok finally, here's a very short list of some of the commonly used Identifiers in mIRC scripting. Just to get you interested in them actually. You are admonished to look up Identifiers in the Help File. I am stressing it again, till you know most of the Identifiers there isn't much you can do. The list follows:
$1 returns the first parameter of an input.
$2 returns the second parameter of an input.
$1- returns all the parameters from the first parameter onwards.
$3- returns all the parameters from the third parameter onwards.
$2-5 returns all the parameters from the 2nd to the 5th.
$time returns the current time on your computer.
$fulldate you guessed it right.
$day you guessed it right again.
$mircdir returns the mIRC directory.
$mircexe returns the full path and filename of the mIRC exe file.
$lines(filename) returns the number of lines in the file named "filename".
$read(filenam,5) reads the 5th line in the file named "filename".
$me returns your nick.
$nick returns the nick which caused an event. You need to know about
Remotes.
$snicks returns the selected nicks in the nick list.
$asc(A) returns the ASCII number of character A.
$chr(65) returns the character of ASCII number 65.
$base(25,10,16) converts 25 from base 10 (decimal) to base 16 (hexadecimal) and of course returns the value .
$len(text) returns the length of text.
$rand(1,9) returns a random character between 1 and 9.
$r(A,Z) returns a random character between A and Z. It's the shorter version of $rand().
$upper(text) returns text in uppercase.
$network returns the network you are connected to.
$server returns the server you are connected to.
$ip returns your IP number.
$os returns the type of your Operating System.
$version returns the version of mIRC you are using.
$?="Text" pops up an input dialog box and returns the input. To see an example type
//echo -a $?="Type something"
$?*="Text" pops up a password input dialog box and returns the value.

To see an example type
//echo -a $?*="Enter Password"
$?!="Text" pops up a decision box and returns $true or $false.

To see an example type
//echo -a $?!="Would you like to reconnect?"
$iff(C,T,F) returns T if the condition C is true, else F. Eg:
//echo -a $iif(1 == 2,Yes, No). Similar to If-Else, but in only one line.
$& lets you break up a single long line to multiple lines which are combined when the script is execute.
Just look at the things you can do with these few Identifiers. There are many many more useful Identifiers, refer the Help File. The Identifiers from the categories of Time and Date, File and Directories, Nick and Address, Text and Numbers and Other Identifiers are a must-know. Other Identifiers, you can learn as you start writing more complex scripts and when necessary. With this I close the chapter on Identifiers. Next we will be learning about another vast and important subject on mIRC scripting - Commands.
Back
|
Table of Contents
|
Commands
Copyright © 2002-2004 SpyderWares.
Feel free to distribute this tutorial in part or whole, just make sure the credits stay intact.
http://spyderwares.com